package com.hq.bootdemo.controller;

import com.yq.superMarket.test.MD5Util;
import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.GetMapping;


import javax.servlet.http.HttpSession;


@Controller
public class MainController {
    @GetMapping({"/","/login"})
    public String login(){
        System.out.println(MD5Util.getDigest("123456"));
        return "login";
    }

    @GetMapping("/home")
    public String home(HttpSession session){
        if(session.getAttribute("curUser") == null)return "login";
        return "home";
    }

    @GetMapping("/logout")
    public String logout(HttpSession session){
        session.invalidate();
        return "login";
    }
}
